<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 任务组重试</title>
    <meta name="keywords" content="ZDH 任务组重试">
    <meta name="description" content="ZDH 任务组重试">

    <link rel="shortcut icon" href="img/favicon.ico">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="css/plugins/datetimepicker/datetimepicker.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>任务组配置</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">

                    <form id="dispatch_task_add_form" name="dispatch_task_add_form" method="post" class="form-horizontal"
                          action="">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">子任务</label>
                            <div class="col-sm-10">
                                <div class="checkbox i-checks" id="sub_task_div">

                                </div>
                            </div>

                        </div>

                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <div class="text-center">
                                <button id="execute" name="execute" class="btn btn-primary" οnsubmit='return false'
                                        type="button">执行
                                </button>
                                <button id="execute_newversion" name="execute" class="btn btn-default" οnsubmit='return false'
                                        type="button">最新版执行
                                </button>
                                <button id="cancel" name="cancel" class="btn btn-white" οnsubmit='return false'
                                        type="button">取消
                                </button>
                            </div>
                        </div>


                    </form>


                </div>
            </div>



        </div>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>

<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>

<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>

<script src="js/plugins/layer/laydate/laydate.js"></script>

<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });

    });

    (function(document, window, $) {


        (function () {

            var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
            var params = url.substr(1);//去掉问号
            var pa = params.split("&");
            var s = new Object();
            for(var i = 0; i < pa.length; i ++){
                s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
            }

            //获取所有子任务
            function get_all_tasks(){
                var job_id=s.job_id
                var t_id=s.id
                $.ajax({
                    type: 'POST',
                    url: "task_group_log_instance_list3",
                    dataType: 'json',
                    data: "ids="+t_id,
                    //发送数据前
                    beforeSend: function () {

                    },
                    //成功返回
                    success: function (data) {


                       if(data.length=1){

                           $('#sub_task_div').empty()
                           $('#sub_task_div').addClass("checkbox")
                           $('#sub_task_div').addClass("i-checks")
                           var jsplumb_json=JSON.parse(data[0].jsmind_data)

                           for(var i=0;i<jsplumb_json.tasks.length;i++){
                               var divId=jsplumb_json.tasks[i].divId
                               $('#sub_task_div').append('<label class="no-padding">')
                               $('#sub_task_div').append('<input type="checkbox" name="sub_tasks" value='+divId +' divId='+ divId+' checked=""><i></i>'+jsplumb_json.tasks[i].etl_context+'</label>')
                           }

                           // for(var i=0;i<jsplumb_json.tasks.length;i++){
                           //     var divId=jsplumb_json.tasks[i].divId
                           //     $('#sub_task_div').append('<label class="no-padding">')
                           //     $('#sub_task_div').append('<input type="checkbox" name="sub_tasks" value='+divId +' divId='+ divId+' checked=""><i></i>'+jsplumb_json.tasks[i].etl_context+'</label>')
                           // }
                           // for(var i=0;i<jsplumb_json.shell.length;i++){
                           //     var divId=jsplumb_json.shell[i].divId
                           //     $('#sub_task_div').append('<label class="no-padding">')
                           //     $('#sub_task_div').append('<input type="checkbox" name="sub_tasks" value='+divId +' divId='+ divId+' checked=""><i></i>'+jsplumb_json.shell[i].etl_context+'</label>')
                           // }

                           $('.i-checks').iCheck({
                               checkboxClass: 'icheckbox_square-green',
                               radioClass: 'iradio_square-green',
                           });

                       }

                    },
                    //处理完成
                    complete: function () {
                        console.info("complete")
                    },
                    //报错
                    error: function (data) {
                        console.info("error: " + data.responseText);
                    }
                });


            }

            get_all_tasks()
        })();



    })(document, window, jQuery);

    $('#execute').click(function () {


        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();
        for(var i = 0; i < pa.length; i ++){
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }

        $.ajax({
                url: "retryJobGroup",
                data:  $("#dispatch_task_add_form").serialize()+"&id=" + s.id+"&new_version=false",
                type: "post",
                dataType: "json",
                success: function (data) {
                    console.info("success")
                },
                error: function (data) {
                    console.info("error: " + data.responseText);
                },
                //处理完成
                complete: function () {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                    console.info("complete")
                }
            });


    })

    $('#execute_newversion').click(function () {


        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();
        for(var i = 0; i < pa.length; i ++){
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }

        $.ajax({
            url: "retryJobGroup",
            data: $("#dispatch_task_add_form").serialize()+"&id=" + s.id+"&new_version=true",
            type: "post",
            dataType: "json",
            success: function (data) {
                console.info("success")
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },
            error: function (data) {
                console.info("error: " + data.responseText);
            },
            //处理完成
            complete: function () {
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                console.info("complete")
            }

        });


    })

    $('#cancel').click(function () {

        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();
        for(var i = 0; i < pa.length; i ++){
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭

    })

</script>

</body>

</html>
